﻿Public Class PhanCongDAO
    Public Shared Function SelectAll() As DataTable
        Dim strSQL As String = "select * from PHANCONG"
        Dim dt As DataTable
        dt = Provider.ExecQuery(strSQL)
        Return dt
    End Function

    Public Shared Sub Insert(ByVal _pc As PhanCongDTO)
        Dim strSQL As String = "Insert into PHANCONG(MaGV, NgayDay, GioDay, SoTiet, MaPhong, MaLop)  Values(" & _pc.MaGV & ",'" & _pc.NgayDay & "','" & _pc.GioDay & "'," & _pc.SoTiet & "," & _pc.MaPhong & "," & _pc.MaLop & ")"
        Provider.ExecNoneQuery(strSQL)
    End Sub

    Public Shared Sub Delete(ByVal _pc As PhanCongDTO)
        Dim strSQL As String = "delete from PHANCONG where MaPhanCong = " & _pc.MaPhanCong
        Provider.ExecNoneQuery(strSQL)
    End Sub

    Public Shared Sub Update(ByVal _pc As PhanCongDTO)
        Dim strSQL As String = "Update PHANCONG set MaGV = " & _pc.MaGV & ", NgayDay = '" & _pc.NgayDay & "', GioDay = '" & _pc.GioDay & "', SoTiet = " & _pc.SoTiet & ", MaPhong = " & _pc.MaPhong & ", MaLop = " & _pc.MaLop & " where MaPhanCong = " & _pc.MaPhanCong
        Provider.ExecNoneQuery(strSQL)
    End Sub

    Public Shared Function SelectByGV(ByVal strSQl As String) As DataTable
        Dim _dt As DataTable
        'Dim strSQL As String = "select GV.MaGV, GV.HoTen, PH.TenPhong, LH.TenLop from GIAOVIEN GV, LOPHOC LH, PHONGHOC PH, PHANCONG PC, CHUYENMON CM where GV.MaGV=PC.MaGV and PH.MaPhong=PC.MaPhong and PC.MaLop=LH.MaLop and GV.MaChuyenMon=CM.MaChuyenMon and GV.MaGV = " & _pc & " and MaChuyenMon = "
        _dt = Provider.ExecQuery(strSQL)
        Return _dt
    End Function

End Class
